package com.ty.zls.components;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;

import com.qmuiteam.qmui.widget.QMUIRadiusImageView;
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton;
import com.ty.zls.R;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

public class ImageAttachView extends RelativeLayout {

    @ViewInject(R.id.qiv_water_attch)
    private QMUIRadiusImageView qiv_water_attch;
    @ViewInject(R.id.qrb_close_attach)
    private QMUIRoundButton qrb_close_attach;
    @ViewInject(R.id.qrb_add_attach)
    private QMUIRoundButton qrb_add_attach;
    @ViewInject(R.id.rl_pic_attch)
    private RelativeLayout rl_pic_attch;

    private OnClickListener imageListener;

    public ImageAttachView(Context context) {
        super(context);
        LayoutInflater.from(context).inflate(R.layout.image_view_fragment, this);

        x.view().inject(this);
    }

    public void setImageListener(OnClickListener clickListener) {
        this.imageListener = clickListener;
        qrb_close_attach.setOnClickListener(imageListener);
        qrb_add_attach.setOnClickListener(imageListener);
    }

    /**
     * 设置附件图片
     */
    public void setImage(Bitmap bitmap){
        qiv_water_attch.setImageBitmap(bitmap);
    }


    public void showImage(){
        rl_pic_attch.setVisibility(VISIBLE);
        qrb_add_attach.setVisibility(GONE);
    }

    public void hideImage(){
        rl_pic_attch.setVisibility(GONE);
        qrb_add_attach.setVisibility(VISIBLE);
    }

}
